package com.example.crossborderecommerce.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.crossborderecommerce.entity.Role;
import com.example.crossborderecommerce.mapper.RoleMapper;
import com.example.crossborderecommerce.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yolanda
 * @since 2024-05-09
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
    @Resource
    RoleMapper roleMapper;
    @Override
    public String findNameByAuthority(String authority) {
        QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("authority", authority);
        Role role = roleMapper.selectOne(queryWrapper);
        if(role == null) {
            return "";
        }
        return role.getName();
    }
}
